package com.nikitova.craps3d {
	import com.carlcalderon.arthropod.Debug;
	import com.nikitova.craps3d.constants.Notifications;
	import com.nikitova.craps3d.controller.CreateCommand;

	import org.puremvc.as3.multicore.interfaces.*;
	import org.puremvc.as3.multicore.patterns.facade.*;

	/**
	 * @author schranz
	 */
	public class ApplicationFacade extends Facade implements IFacade
	{
		private var _main : Main;
		/**
		 * Create the application
		 */
		public function ApplicationFacade( key : String, main : Main )
		{
			super(key);
			_main = main;
			sendNotification(Notifications.CREATE, _main);	
		}
		/**
		 * Singleton ApplicationFacade Factory Method
		 */
		public static function getInstance( key : String, main : Main ) : ApplicationFacade
		{
			if ( instanceMap[ key ] == null ) 
 				instanceMap[ key ] = new ApplicationFacade(key, main);
 				
			return ApplicationFacade(instanceMap[ key ]);
		}
		/**
		 * Register Commands with the Controller 
		 */
		override protected function initializeController( ) : void 
		{
			super.initializeController();	
			registerCommand(Notifications.CREATE, CreateCommand);	
		}
		/**
		 * Start the application
		 */
		public function startup() : void
		{
			sendNotification(Notifications.STARTUP);
		}
		/**
		 * Close the application
		 */
		public function close() : void
		{
			sendNotification(Notifications.CLOSE);
		}
	}
}
